﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Text;

namespace MShop.Core.Domain
{

    [MetadataType(typeof(ProductComment_Validation))]
    public partial class ProductComment
    {
        public ProductComment()
        {
            this.Created = DateTime.Now;
            this.Modified = DateTime.Now;
            this.JsonType = "10";
        }


        public string JsonType
        {
            get;
            set;
        }

        public string StarImage 
        {
            get
            {
                return string.Format("<img src='/images/product/good{0}.jpg' />", Star);
            }
        }

        public string ShowUserName()
        {
            string abc = "abcdefghijklmnopqrstuvwxyz";
            StringBuilder sb = new StringBuilder();
            if("匿名用户"==UserName)
            {
                int i = new Random(this.Id).Next(0,24);
                return "****"+abc[i];
            }
            int length = UserName.Length;
            for (int i = 0; i < length; i++)
            {
                sb.Append("*");
            }
            sb.Append(UserName.Substring(length - 1, 1));
            return sb.ToString();
        }


    }

    internal partial class ProductComment_Validation
    {
       
    }
}